import {
	baseUrl
} from './config.js'

function getApi(city){
	let base1 = 'https://api.seniverse.com/v3/weather/now.json?key=';
	let key = 'SwvaEmbJeRjyr9DTn';
	let base2 = '&location=';
	let base3  = '&language=zh-Hans&unit=c'
	// return base1 + key + base2 + city + base3;
	return 'https://api.seniverse.com/v3/weather/daily.json?key='+key+'&location='+city+'&language=zh-Hans&unit=c&start=-1&days=5'
	
}

export function cityWeather(city) {
	let api = getApi(city).toString();
	// console.log(api);

	return new Promise(function(reslove, reject) {

		uni.request({
			url: `${api}`,
			method: 'GET',
			success: res => {
				console.log(res.data)
				let result = res.data.results[0]
				reslove(result);
			}
		});

	});

}